package mapper;

import com.itany.jdbc.jdbc.RowMapper;
import pojo.User;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 陈华旺
 * @version 1.0
 * @date 2023年10月25日 17:26
 * @Description TODO
 */
public class UserMapper implements RowMapper<User> {
    @Override
    public List<User> mapperRow(ResultSet rs) throws SQLException {
        List<User> list = new ArrayList<>();
        while ( rs.next() ){
            User u = new User();
            u.setId( rs.getInt("id") );
            u.setName( rs.getString("name") );
            u.setSex( rs.getInt("sex") );
            u.setPassword( rs.getString("password") );
            u.setUsername( rs.getString("username") );
            list.add(u);
        }
        return list;
    }
}
